package mid;

public class a167_两数之和II输入有序数组 {
    public int[] twoSum(int[] numbers, int target) {
        int[] ans = new int[2];
        int sum=0;
        for (int i = 0,j=numbers.length-1 ; i<j;) {
            sum=numbers[i]+numbers[j];
            if (sum==target){
                ans[0]=i+1;
                ans[1]=j+1;
                return ans;
            }else if (sum>target) j--;
            else i++;
        }
        return null;
    }
}
